package org.gten.gegedexin.service;

import org.apache.ibatis.annotations.Select;
import org.gten.gegedexin.dao.DraftDao;
import org.gten.gegedexin.pojo.DraftPojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author Eric
 * @date 2023/6/29
 */

@Service
public class DraftServiceImpl {
    @Autowired
    DraftDao draftDao;

    public List<DraftPojo> getDraftBySender(String sender){
        return draftDao.getDraftBySender(sender);
    }

    public int getValidId(){
        return draftDao.getValidInfoId();
    }

    public void addDraft(String receiver, String sender, String header, String context, LocalDateTime editTime){
        draftDao.insert(new DraftPojo(getValidId()+1, receiver, sender, header, context, editTime));
    }

    public void delDraft(int id){
        draftDao.deleteById(id);
    }

    public DraftPojo getDraftById(int ID){
        return draftDao.selectById(ID);
    }
}

